package com.yunhe.merchants.client.fallback;

import com.yunhe.common.exception.ArgumentErrorException;
import com.yunhe.common.exception.ModelNotFoundException;
import com.yunhe.common.exception.ObjectNotFoundException;
import com.yunhe.common.exception.UniqueConstraintsException;
import com.yunhe.common.model.ResultObject;
import com.yunhe.common.model.authority.User;
import com.yunhe.common.model.company.ContractAccessories;
import com.yunhe.common.util.FallbackUtil;
import com.yunhe.merchants.client.AuthorityClient;
import feign.hystrix.FallbackFactory;
import org.springframework.http.ResponseEntity;

import java.util.List;

/**
 * @Author: DongWenYu
 * @Date: 2021/2/23 14:27
 */
public class AuthorityClientFallbackFactory implements FallbackFactory<AuthorityClient> {
    @Override
    public AuthorityClient create(Throwable cause) {
        return new AuthorityClient() {
            @Override
            public ResponseEntity<ResultObject> getSubOrg(String orgId) {
                return FallbackUtil.getDefaultFallBack();
            }

            @Override
            public ResponseEntity<ResultObject> getOrgByLoginUser(Long firmId, Long stationId, String orgFunction, Boolean childFlag) {
                return FallbackUtil.getDefaultFallBack();
            }

            @Override
            public ResponseEntity<ResultObject> getOfficeById(Long officeId) {
                return FallbackUtil.getDefaultFallBack();
            }

            @Override
            public ResponseEntity<ResultObject> getUserByStationIdAndOrg(Long stationId, List<Long> orgIds, String roleType) {
                return FallbackUtil.getDefaultFallBack();
            }

            @Override
            public ResponseEntity<ResultObject> getUserByPhone(String phone) {
                return FallbackUtil.getDefaultFallBack();
            }

            @Override
            public ResponseEntity<ResultObject> getUserByOrgAndRoleName(Long orgId, String roleName, Long stationId, Long firmId) {
                return FallbackUtil.getDefaultFallBack();
            }

            @Override
            public ResponseEntity<ResultObject> searchOrgByStationId(Long stationId, Long firmId) {
                return FallbackUtil.getDefaultFallBack();
            }


            @Override
            public ResponseEntity<ResultObject<User>> get(Long id) {
                return FallbackUtil.getDefaultFallBack();
            }

            @Override
            public ResponseEntity<ResultObject> findByStationIdAndOfficeTitle(Long stationId, String officeTitle) {
                return FallbackUtil.getDefaultFallBack();
            }

            @Override
            public ResponseEntity<ResultObject<String>> intentionToCompany(Long intentionId, String officeIds, String title, String leaseTime, String leaseDueTime, List<ContractAccessories> contractAccessoriesList) throws ObjectNotFoundException, UniqueConstraintsException, ArgumentErrorException {
                return FallbackUtil.getDefaultFallBack();
            }

            @Override
            public ResponseEntity<ResultObject> setOfficeStatus(Long intentionId, Long chosenOffice, String companyName, String stauts) throws ArgumentErrorException, ModelNotFoundException {
                return FallbackUtil.getDefaultFallBack();
            }
        };
    }
}
